package com.ruoyi.web.controller.sj.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.sj.domain.WqEweiShopMerchUser;
import com.ruoyi.sj.service.IWqEweiShopMerchUserService;
import com.ruoyi.web.core.base.BaseController;
import com.ruoyi.framework.web.page.TableDataInfo;
import com.ruoyi.common.base.AjaxResult;

/**
 * 商户 信息操作处理
 * 
 * @author tyc@yanyu.com
 * @date 2019-01-03
 */
@Controller
@RequestMapping("/sj/wqEweiShopMerchUser")
public class WqEweiShopMerchUserController extends BaseController
{
    private String prefix = "sj/wqEweiShopMerchUser";
	
	@Autowired
	private IWqEweiShopMerchUserService wqEweiShopMerchUserService;
	
	@RequiresPermissions("sj:wqEweiShopMerchUser:view")
	@GetMapping()
	public String wqEweiShopMerchUser()
	{
	    return prefix + "/wqEweiShopMerchUser";
	}
	
	/**
	 * 查询商户列表
	 */
	@RequiresPermissions("sj:wqEweiShopMerchUser:list")
	@PostMapping("/list")
	@ResponseBody
	public TableDataInfo list(WqEweiShopMerchUser wqEweiShopMerchUser)
	{
		startPage();
        List<WqEweiShopMerchUser> list = wqEweiShopMerchUserService.selectWqEweiShopMerchUserList(wqEweiShopMerchUser);
		return getDataTable(list);
	}
	
	/**
	 * 新增商户
	 */
	@GetMapping("/add")
	public String add()
	{
	    return prefix + "/add";
	}
	
	/**
	 * 新增保存商户
	 */
	@RequiresPermissions("sj:wqEweiShopMerchUser:add")
	@Log(title = "商户", businessType = BusinessType.INSERT)
	@PostMapping("/add")
	@ResponseBody
	public AjaxResult addSave(WqEweiShopMerchUser wqEweiShopMerchUser)
	{		
		return toAjax(wqEweiShopMerchUserService.insertWqEweiShopMerchUser(wqEweiShopMerchUser));
	}

	/**
	 * 修改商户
	 */
	@GetMapping("/edit/{id}")
	public String edit(@PathVariable("id") Integer id, ModelMap mmap)
	{
		WqEweiShopMerchUser wqEweiShopMerchUser = wqEweiShopMerchUserService.selectWqEweiShopMerchUserById(id);
		mmap.put("wqEweiShopMerchUser", wqEweiShopMerchUser);
	    return prefix + "/edit";
	}
	
	/**
	 * 修改保存商户
	 */
	@RequiresPermissions("sj:wqEweiShopMerchUser:edit")
	@Log(title = "商户", businessType = BusinessType.UPDATE)
	@PostMapping("/edit")
	@ResponseBody
	public AjaxResult editSave(WqEweiShopMerchUser wqEweiShopMerchUser)
	{		
		return toAjax(wqEweiShopMerchUserService.updateWqEweiShopMerchUser(wqEweiShopMerchUser));
	}
	
	/**
	 * 删除商户
	 */
	@RequiresPermissions("sj:wqEweiShopMerchUser:remove")
	@Log(title = "商户", businessType = BusinessType.DELETE)
	@PostMapping( "/remove")
	@ResponseBody
	public AjaxResult remove(String ids)
	{		
		return toAjax(wqEweiShopMerchUserService.deleteWqEweiShopMerchUserByIds(ids));
	}
	
}
